<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="">
        <!-- maxlenth 设置最大输入长度 -->
        <input type="text" id="username" maxlength="5">
        <input type="submit">
    </form>
</body>
<script>
    var username = document.querySelector("#username")
    //.validity 输出验证状态,包含多个值
    console.log(username.validity);
</script>
</html>